/* 
 * File:   WB.cpp
 * Author: antonio
 * 
 * Created on 2 de Junho de 2010, 19:53
 */

#include "WB.h"
#include "estruturas.h"

WB::WB(registradores* _regs, EXEC* _exec) {

    this->exec = _exec;
    this->regs = _regs;

    s_mapStringRegs["rt0"] = rt0;
    s_mapStringRegs["rt1"] = rt1;
    s_mapStringRegs["rt2"] = rt2;
    s_mapStringRegs["rt3"] = rt3;
    s_mapStringRegs["rt4"] = rt4;
    s_mapStringRegs["rt5"] = rt5;
    s_mapStringRegs["rt6"] = rt6;
    s_mapStringRegs["rt7"] = rt7;

}

WB::WB(const WB& orig) {
}

WB::~WB() {
}

void WB::executa(bufferEXEC buffer) {
    if (buffer.acao) {

        switch (s_mapStringRegs[buffer.id]) {
            case rt0:
                return regs->SetR0(buffer.r);
                break;
            case rt1:
                return regs->SetR1(buffer.r);
                break;
            case rt2:
                return regs->SetR2(buffer.r);
                break;
            case rt3:
                return regs->SetR3(buffer.r);
                break;
            case rt4:
                return regs->SetR4(buffer.r);
                break;
            case rt5:
                return regs->SetR5(buffer.r);
                break;
            case rt6:
                return regs->SetR6(buffer.r);
                break;
            case rt7:
                return regs->SetR7(buffer.r);
                break;

        }
    }
}

